package cn.tedu.ivos.repair.controller;

import cn.tedu.ivos.base.response.JsonResult;
import cn.tedu.ivos.repair.pojo.dto.RepairQuery;
import cn.tedu.ivos.repair.pojo.dto.RepairSaveParam;
import cn.tedu.ivos.repair.pojo.vo.RepairVO;
import cn.tedu.ivos.repair.service.RepairService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/v1/repair")
@Slf4j
public class RepairController {
    @Autowired
    RepairService repairService;
    @GetMapping("select")
    public JsonResult selectRepair(RepairQuery repairQuery){
        log.debug("开始处理【查询维修单】的请求，参数：{}",repairQuery);
        List<RepairVO> list = repairService.selectRepair(repairQuery);
        return JsonResult.ok(list);
    }
    @PostMapping("save")
    public JsonResult saveRepair(RepairSaveParam repairSaveParam){
        log.debug("开始处理【保存维修单】的请求，参数：{}",repairSaveParam);
        repairService.saveRepair(repairSaveParam);
        return JsonResult.ok();
    }
    @PostMapping("delete")
    public JsonResult deleteRepair(Long id){
        log.debug("开始处理【删除维修单】的请求，参数：{}",id);
        repairService.deleteRepair(id);
        return JsonResult.ok();
    }
}
